home *** CD-ROM | disk | FTP | other *** search
/ Kit PC World De Ampliacion De Windows 95 / Kit PC World de ampliacion de Windows 95.iso / clarion / cw15 / tpw15.z / PROCESS.TPW < prev    next >
Text File  |  1995-09-06  |  9KB  |  235 lines

  1. #PROCEDURE(Process,'Sequential Record Processor'),PRIMARY('File(s) to Process',OPTKEY),HLP('~TPLProcProcess')
  2. #! Note that range limits are considered to be loop invariant
  3. #! This reduces code and loop overhead and allows on-server filters
  4. #! To use fresh limits an explicit filter re-assignment is needed
  5. #LOCALDATA
  6. RejectRecord         LONG,AUTO
  7. LocalRequest         LONG,AUTO
  8. LocalResponse        LONG,AUTO
  9. WindowOpened         LONG,AUTO
  10. RecordsToProcess     LONG,AUTO
  11. RecordsProcessed     LONG,AUTO
  12. RecordsPerCycle      LONG,AUTO
  13. RecordsThisCycle     LONG,AUTO
  14. PercentProgress      BYTE
  15. RecordStatus         BYTE,AUTO
  16. #ENDLOCALDATA
  17. #PROMPT('P&arameters:', @s255), %Parameters
  18. #ENABLE(%ProcedureType='FUNCTION')
  19.   #PROMPT('Return Value:',FIELD),%ReturnValue
  20. #ENDENABLE
  21. #BUTTON('&Process Properties'),AT(10,,180)
  22.   #SHEET
  23.     #TAB('&General'),HLP('~TPLProcProcess_General')
  24.       #PROMPT('Window Message:',@S40),%WindowMessage
  25.       #PROMPT('Action for Process:',DROP('No record action|PUT record|DELETE record')),%ProcessAction,DEFAULT('No record action')
  26.       #PROMPT('Quick-Scan Records',CHECK),%EnableQuickScan,DEFAULT(1)
  27.       #PROMPT('&Record Filter:',@S255),%RecordFilter
  28.       #ENABLE(%RecordFilter OR %RangeField)
  29.         #PROMPT('Approx. Record Count:',@N6),%ApproxRecordCount,REQ
  30.       #ENDENABLE
  31.     #ENDTAB
  32.     #TAB('Range Limits'),WHERE(%PrimaryKey),HLP('~TPLProcProcess_Range_Limits')
  33.       #ENABLE(%PrimaryKey),CLEAR
  34.         #PROMPT('Range Limit &Field:',COMPONENT(%PrimaryKey)),%RangeField
  35.       #ENDENABLE
  36.       #ENABLE(%RangeField)
  37.         #PROMPT('Range Limit &Type:',DROP('Current Value|Single Value|Range of Values|File Relationship')),%RangeLimitType,DEFAULT('Current Value')
  38.         #BOXED('Range Limit Boundary:'),WHERE(%RangeLimitType='Single Value'),AT(,60)
  39.           #PROMPT('&Range Limit Value:',FIELD),%RangeLimit
  40.         #ENDBOXED
  41.         #BOXED('Range Limit Boundaries:'),WHERE(%RangeLimitType='Range of Values'),AT(,60)
  42.           #PROMPT('&Low Limit Value:',FIELD),%RangeLow
  43.           #PROMPT('&High Limit Value:',FIELD),%RangeHigh
  44.         #ENDBOXED
  45.         #BOXED('Range limiting file'),WHERE(%RangeLimitType='File Relationship'),AT(,60)
  46.           #PROMPT('&Related file:',FILE),%RangeFile
  47.         #ENDBOXED
  48.       #ENDENABLE
  49.     #ENDTAB
  50.     #TAB('&Hot Fields'),HLP('~TPLProcProcess_Hot_Fields')
  51.       #BUTTON('Hot Fields'),MULTI(%HotFields,%HotField),INLINE,HLP('~TPLProcProcess_Hot_Fields')
  52.         #PROMPT('Hot Field:',FIELD),%HotField
  53.         #PROMPT('BIND Field',CHECK),%HotFieldBound
  54.       #ENDBUTTON
  55.     #ENDTAB
  56.   #ENDSHEET
  57. #ENDBUTTON
  58. #DECLARE(%ListView)
  59. #SET(%ListView,'Process:View')
  60. #DECLARE(%QueueField),UNIQUE
  61. #DECLARE(%QueueFieldAssignment,%QueueField)
  62. #DECLARE(%ProcessFilter)
  63. #DECLARE(%InstancePrefix)
  64. #DECLARE(%Temp1)
  65. #DECLARE(%Temp2)
  66. #CASE(%RangeLimitType)
  67. #OF('Range of Values')
  68.   #SET(%Temp1,%RangeLow)
  69.   #SET(%Temp2,%RangeHigh)
  70. #OF('Single Value')
  71.   #SET(%Temp1,%RangeLimit)
  72. #OF('File Relationship')
  73.   #SET(%Temp1,%RangeFile)
  74. #ENDCASE
  75. #INSERT(%StandardViewFilter,%RecordFilter,%PrimaryKey,%RangeField,%RangeLimitType,'Process:Save:',%Temp1,%Temp2,'Construct')
  76. #SET(%ProcessFilter,%ValueConstruct)
  77. #DECLARE(%ListViewBoundField),UNIQUE
  78. #FOR (%QueueField)
  79.   #SET(%QueueFieldAssignment,%QueueField)
  80.   #ADD(%ListViewBoundField,%QueueField)
  81. #ENDFOR
  82. #FOR (%HotFields)
  83.   #ADD(%QueueField,%HotField)
  84.   #SET(%QueueFieldAssignment,%HotField)
  85.   #IF (%HotFieldBound)
  86.     #ADD(%ListViewBoundField,%HotField)
  87.   #ENDIF
  88. #ENDFOR
  89. #FOR (%Formula), WHERE( ITEMS(%FormulaField) )
  90.   #FOR (%FormulaField)
  91.     #ADD(%QueueField,%FormulaField)
  92.     #SET(%QueueFieldAssignment,%FormulaField)
  93.   #ENDFOR
  94. #ENDFOR
  95. #AT(%CustomGlobalDeclarations)
  96.   #INSERT(%StandardGlobalSetup)
  97. #ENDAT
  98. #CLASS('Procedure Setup','Upon Entry into the Procedure')
  99. #CLASS('Before Lookups','After Record Retrieved, Before Lookups')
  100. #CLASS('After Lookups','After Record Retrieved, After Lookups')
  101. #CLASS('Procedure Exit','Before Leaving the Procedure')
  102. #CLASS('Before Range Check','In Validate Record ROUTINE, Before Range Limit Code')
  103. #CLASS('Before Filter Check','In Validate Record ROUTINE, Before Filter Code')
  104. #INSERT(%FileControlInitialize)
  105. #EMBED(%GatherSymbols,'Gather Template Symbols'),HIDE
  106. %Procedure %ProcedureType%Parameters
  107. #INSERT(%StandardViewFilter,%RecordFilter,%PrimaryKey,%RangeField,%RangeLimitType,'Process:Save:',%Temp1,%Temp2,'Declare')
  108. #INSERT(%ProcessDeclarations)
  109. #INSERT(%ConstructView)
  110. #INSERT(%StandardProgressWindow)
  111.   CODE
  112.   #EMBED(%ProcedureSetup,'Procedure Setup')
  113.   #FOR( %ListViewBoundField )
  114.     #FIND(%Field,%ListViewBoundField)
  115.     #IF (NOT %FieldFile OR %FieldName)
  116.   BIND('%ListViewBoundField',%ListViewBoundField)
  117.     #ENDIF
  118.   #ENDFOR
  119.   #INSERT(%StandardViewFilter,%RecordFilter,%PrimaryKey,%RangeField,%RangeLimitType,'Process:Save:',%Temp1,%Temp2,'Bind')
  120.   LocalRequest = GlobalRequest
  121.   LocalResponse = RequestCancelled
  122.   CLEAR(GlobalRequest)
  123.   CLEAR(GlobalResponse)
  124.   #INSERT(%StandardFormula,'Procedure Setup')
  125.   #INSERT(%FileControlOpen)
  126.   #EMBED(%BeforeAccept,'Preparing to Process the Window')
  127.   #INSERT(%StandardViewFilter,%RecordFilter,%PrimaryKey,%RangeField,%RangeLimitType,'Process:Save:',%Temp1,%Temp2,'Save')
  128.   #MESSAGE('Accept Handling',3)
  129.   #IF(%PrimaryKey)
  130.     #IF(%RecordFilter OR %RangeField)
  131.   RecordsToProcess = %ApproxRecordCount
  132.     #ELSE
  133.   RecordsToProcess = RECORDS(%Primary)
  134.     #ENDIF
  135.   RecordsPerCycle = 25
  136.   #ELSE
  137.     #IF(%RecordFilter)
  138.   RecordsToProcess = %ApproxRecordCount
  139.     #ELSE
  140.   RecordsToProcess = BYTES(%Primary)
  141.     #ENDIF
  142.   RecordsPerCycle = 1000
  143.   #ENDIF
  144.   RecordsProcessed = 0
  145.   PercentProgress = 0
  146.   #EMBED(%BeforeOpeningWindow,'Before Opening Progress Window')
  147.   OPEN(ProgressWindow)
  148.   #CASE(%ProcessAction)
  149.   #OF('Put Record')
  150.   ProgressWindow{Prop:Text} = 'Updating Records'
  151.   #OF('Delete Record')
  152.   ProgressWindow{Prop:Text} = 'Deleting Records'
  153.   #ELSE
  154.   ProgressWindow{Prop:Text} = 'Processing Records'
  155.   #ENDCASE
  156.   ?Progress:PctText{Prop:Text} = '0% Completed'
  157.   #IF(SUB(%WindowMessage,1,1)='!')
  158.     #SET(%ValueConstruct,SUB(%WindowMessage,2,LEN(%WindowMessage)-1))
  159.   ?Progress:UserString{Prop:Text}=%ValueConstruct
  160.   #ELSE
  161.   ?Progress:UserString{Prop:Text}='%'WindowMessage'
  162.   #ENDIF
  163.   #IF(%EnableQuickScan)
  164.   #EMBED(%BeforeTurnQuickScanOn,'Before Turning QuickScan On'),WHERE(%EnableQuickScan)
  165.   SEND(%Primary,'QUICKSCAN=on')
  166.     #FOR(%Secondary),WHERE(%SecondaryType = '1:MANY')
  167.   SEND(%Secondary,'QUICKSCAN=on')
  168.     #ENDFOR
  169.   #EMBED(%AfterTurnQuickScanOn,'After Turning QuickScan On'),WHERE(%EnableQuickScan)
  170.   #ENDIF
  171.   ACCEPT
  172.     CASE EVENT()
  173.     OF Event:OpenWindow
  174.       #INSERT(%ProcessSaveLimits)
  175.     OF Event:Timer
  176.       RecordsThisCycle = 0
  177.       LOOP WHILE RecordsThisCycle < RecordsPerCycle
  178.         #INSERT(%ProcessEventTimer)
  179.         LOOP
  180.           #EMBED(%BeforeSubsequentRead,'Before subsequent record retrieval')
  181.           DO GetNextRecord
  182.           #EMBED(%AfterSubsequentRead,'After subsequent record retrieval')
  183.           DO ValidateRecord
  184.           CASE RecordStatus
  185.             OF Record:OutOfRange
  186.               LocalResponse = RequestCancelled
  187.               BREAK
  188.             OF Record:OK
  189.               BREAK
  190.           END
  191.         END
  192.         IF LocalResponse = RequestCancelled
  193.           LocalResponse = RequestCompleted
  194.           BREAK
  195.         END
  196.         LocalResponse = RequestCancelled
  197.       END
  198.       IF LocalResponse = RequestCompleted
  199.         ?Progress:PctText{Prop:Text} = 'Process Completed'
  200.         DISPLAY(?Progress:PctText)
  201.         POST(Event:CloseWindow)
  202.       END
  203.     END
  204.     CASE FIELD()
  205.     OF ?Progress:Cancel
  206.       CASE Event()
  207.       OF Event:Accepted
  208.         LocalResponse = RequestCancelled
  209.         POST(Event:CloseWindow)
  210.       END
  211.     END
  212.   END
  213.   #INSERT(%ProcessEndOfProcedure)
  214.   DO ProcedureReturn
  215. #!---------------------------------------------------------------------
  216. ProcedureReturn ROUTINE
  217.   #INSERT(%FileControlClose)
  218.   #EMBED(%EndOfProcedure,'End of Procedure')
  219.   #INSERT(%StandardFormula,'Procedure Exit')
  220.   IF LocalResponse
  221.     GlobalResponse = LocalResponse
  222.   ELSE
  223.     GlobalResponse = RequestCancelled
  224.   END
  225.   #IF(%ReturnValue)
  226.   RETURN(%ReturnValue)
  227.   #ELSE
  228.   RETURN
  229.   #ENDIF
  230. #INSERT(%ProcessValidateRecord)
  231. #INSERT(%ProcessGetRecords)
  232. #!---------------------------------------------------------------------
  233. #EMBED(%ProcRoutines,'Procedure Routines')
  234. #INCLUDE('GPProcess.TPW')
  235.